import unittest
from   vsogame.contril.fund_channel import FundChannel

import os
import logging


class TestFundChannel(unittest.TestCase):
    def setUp(self):
        os.environ['PAYMENT_CLIENT_ID'] = 'szypy3jrnvwfqdahmxdtfh'
        os.environ['PAYMENT_CLIENT_SECRET'] = 'r7wpsjd2wghumt43ewj8e2'
        os.environ['PAYMENT_ENDPOINT'] = 'http://localhost:5010/'
        logging.basicConfig(level=logging.DEBUG
                            )

        console = logging.StreamHandler()
        console.setLevel(logging.DEBUG)
        formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
        console.setFormatter(formatter)
        logging.getLogger('payment').addHandler(console)

    def runTest(self):
        FundChannel.all()

    def test_get_all(self):
        result = FundChannel.all()
        print(result)

    def test_get_one(self):
        channel = FundChannel.find('ALIPAY-0000377489')
        assert channel.success
        assert channel.id == 'ALIPAY-0000377489'
        print(channel)


if __name__ == "__main__":
    unittest.main()
